//
//  PersonInformationViewController.m
//  WeiboAD
//
//  Created by liu guoqiang on 16/7/22.
//  Copyright © 2016年 com.liu.weiboAD. All rights reserved.
//

#import "PersonInformationViewController.h"
#import "PersonTableViewCell.h"
#import "HeaderTableViewCell.h"

@interface PersonInformationViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)HeaderTableViewCell *headerView;

@end

@implementation PersonInformationViewController

- (instancetype)initWithUser:(NSDictionary *)user
{
    self = [super init];
    if (self) {
        _user = [NSDictionary dictionary];
        _user = user;
    }
    return self;
}



- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我的";
    self.personTableView.delegate = self;
    self.personTableView.dataSource = self;
    [self.personTableView registerNib:[UINib nibWithNibName:@"PersonTableViewCell" bundle:nil] forCellReuseIdentifier:@"PersonTableViewCell"];
    [self.personTableView registerNib:[UINib nibWithNibName:@"HeaderTableViewCell" bundle:nil] forCellReuseIdentifier:@"HeaderTableViewCell"];
    
    self.headerView = [self.personTableView dequeueReusableCellWithIdentifier:@"HeaderTableViewCell"];
    self.headerView.nameLabel.text = _user[@"name"];
    self.headerView.favourites_countLabel.text = [NSString stringWithFormat:@"%@",_user[@"favourites_count"]];
    self.headerView.friends_countLabel.text = [NSString stringWithFormat:@"%@",_user[@"friends_count"]];
    self.headerView.statuses_countLabel.text = [NSString stringWithFormat:@"%@",_user[@"statuses_count"]];
    [self.headerView.avatarImageView sd_setImageWithURL:[NSURL URLWithString:_user[@"avatar_large"]] placeholderImage:[UIImage imageNamed:@"资讯选中"]];
    self.personTableView.tableHeaderView = self.headerView;
 
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    PersonTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"PersonTableViewCell" forIndexPath:indexPath];
    if (indexPath.row == 0) {
        cell.contentLabel.text = [NSString stringWithFormat:@"地址: %@",_user[@"location"]];
    }
    return cell;
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
